<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{=T.accepted_language or 'br'}}">
<head>
    <title>{{=response.title or request.application}}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
{{response.files.append(URL(r=request,c='static',f='js/ckeditor/ckeditor.js'))}}
{{response.files.append(URL(r=request,c='static',f='jquery.dataTables.min.js'))}}
{{response.files.append(URL(r=request,c='static',f='demo_table.css'))}}
</head>
{{if vimp!='imp':}}
       {{extend 'layout.html'}}
{{else:}}   
        <table><tr><td><h1>Mestre - Mecanismo Sinérgico de Treinamento</h1></td></tr></table>
{{pass}}  
<table><tr><td colspan=3><h1>Taxonomias das Turmas</h1></td></tr></table>
{{if resposta:}}
   <table>
     <tr><td>{{=button('Nova Pesquisa','grafico')}}</td></tr>     
   </table>
{{else:}}   
  <table>
      <tr><td>{{=pergunta}}</td></tr>
      <tr><td>{{=button('Nova Pesquisa','grafico')}}&nbsp;{{=button('Vista para Impressão','grafico/imp')}}</td></tr>  
  </table>  
{{pass}}    
{{if turma:}}
  <table border=1>
  <tr><td><b>Turma</b></td><td><b>Taxonomia</b></td><td><b>Nota</b></td></tr>
  {{for i in turma:}}
      <tr><td>&nbsp;<a>{{=i['turma']}}</a></td><td>&nbsp;<a>{{=i['taxonomia']}}</a></td><td>&nbsp;<a>{{=i['nota']}}</a></td></tr>
  {{pass}}
  <tr><td colspan=4>
   <script type="text/javascript"
  src="/{{=request.application}}/static/js/protovis-3.1/protovis-r3.1.js"></script>
   <script type="text/javascript">
   var taxonomias={{=resposta}};


     /* Basico dimencionamento */
     var width = 700;
     var height = 700;
     var innerRadius = 90;
     var outerRadius = 300 - 10;

     /* Cores. */
     var drugColor = {
         A: "rgb(10, 50, 100)"
       }, gramColor = {
         positive: "rgba(174, 174, 184, .8)",
         negative: "rgba(230, 130, 110, .8)"
       };

     /* Burtin's radius encoding is, as far as I can tell, sqrt(log(mic)). */
     var max = Math.sqrt(Math.log(1 * 1E4));
     var min = Math.sqrt(Math.log(10 * 1E4));
     var a = (outerRadius - innerRadius) / (min - max);
     var b = innerRadius - a * max;
     function radius(mic) a * Math.sqrt(Math.log(mic * 1E4)) + b;

     /*
      * The pie is split into equal sections for each bacteria, with a blank
      * section at the top for the grid labels. Each wedge is further
      * subdivided to make room for the three antibiotics, equispaced.
      */
     var bigAngle = 2.0 * Math.PI / (taxonomias.length + 1);
     var smallAngle = bigAngle / 7;

     /* The root panel. */
     var vis = new pv.Panel()
         .width(width)
         .height(height)
         .bottom(100);

     /* Background wedges to indicate gram staining color. */
     var bg = vis.add(pv.Wedge)
         .data(taxonomias) // assumes Burtin's order
         .left(width / 2)
         .top(height / 2)
         .innerRadius(innerRadius)
         .outerRadius(outerRadius)
         .angle(bigAngle)
         .startAngle(function(d) this.index * bigAngle + bigAngle / 2 - Math.PI / 2)
         .fillStyle(function(d) gramColor[d.gram]);

     /* Taxonomias */
     bg.add(pv.Wedge)
         .angle(smallAngle)
         .startAngle(function(d) this.proto.startAngle() + smallAngle)
         .outerRadius(function(d) radius(d.A))
         .fillStyle(drugColor.A)
       .add(pv.Wedge)
         .startAngle(function(d) this.proto.startAngle() + 2 * smallAngle)
         .outerRadius(function(d) radius(d.B))
         .fillStyle(drugColor.B)
       .add(pv.Wedge)
         .outerRadius(function(d) radius(d.C))
         .fillStyle(drugColor.C);

     /* Circular grid lines. */
     bg.add(pv.Dot)
         .data(pv.range(-3, 4))
         .fillStyle(null)
         .strokeStyle("#eee")
         .lineWidth(1)
         .size(function(i) Math.pow(radius(Math.pow(10, i)), 2))
       .anchor("top").add(pv.Label)
         .visible(function(i) i < 3)
         .textBaseline("middle")
         .text(function(i) Math.pow(10, i).toFixed((i > 0) ? 0 : -i));

     /* Radial grid lines. */
     bg.add(pv.Wedge)
         .data(pv.range(taxonomias.length + 1))
         .innerRadius(innerRadius - 10)
         .outerRadius(outerRadius + 10)
         .fillStyle(null)
         .strokeStyle("black")
         .angle(0);

     /* Labels. */
     bg.anchor("outer").add(pv.Label)
         .textAlign("center")
         .text(function(d) d.taxonomia);

     /* Taxionomia legend. */
     vis.add(pv.Bar)
         .data(pv.keys(drugColor))
         .right(width / 2 + 3)
         .top(function() height / 2 - 28 + this.index * 18)
         .fillStyle(function(d) drugColor[d])
         .width(36)
         .height(12)
       .anchor("right").add(pv.Label)
         .textMargin(6)
         .textAlign("left");

 

     vis.render();
  </script>
  </td></tr></table>
{{pass}}
